<?php
$departmentarray = array();
foreach($departments as $department){
	$departmentarray[$department['Department']['id']] = $department['Department']['title'];
}
?>

<table>
    <tr>
    	<td>User:</td>
        <td><?php echo h($user['User']['username']); ?></td>
    </tr>
    <tr>
    	<td>Deparment:</td>
        <td><?php echo $departmentarray[$user['User']['department_id']]; ?></td>
    </tr>
    <tr>
    	<td>Cost:</td>
        <td>$<?php echo $user['User']['cost']; ?> per Hour</td>
    </tr>
    <tr>
    	<td>Status:</td>
        <td><?php if($user['User']['publish'] == 1){ echo 'Active user'; }else{ echo 'Inactive user'; } ?></td>
    </tr>
    <tr>
    	<td>Leavedays:</td>
        <td><?php
		if($user['User']['leavedays'] == ''){
			echo 'No leave days allocated';
		}else{
			$leavedays = json_decode($user['User']['leavedays']);
			foreach($leavedays as $key => $leaveday):?>
            	<p><strong>Start date:</strong> <?php echo $leaveday->startdate; ?> <strong>End date:</strong><?php echo $leaveday->enddate; ?></p>
			
            <?php	
            endforeach;
		 	unset($leavedays);
		}
		
		 ?></td>
    </tr>
    <tr>
    	<td>Created:</td>
        <td><?php echo $user['User']['created']; ?></td>
    </tr>
    <tr>
    	<td>Modified:</td>
        <td><?php $user['User']['modified']; ?></td>
    </tr>
</table>
